import request from '../utils/request'
// import store from '@/store'
// 引入接口方法
const userChannelAPI = () => request({
  method: 'GET',
  url: '/v1_0/user/channels'
  // headers: {
  //   Authorization: 'Bearer ' + store.state.token
  // }
})
// 时间的接口
const articlesListAPI = ({ channId, timestamp = Date.now() + '' }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channId,
      timestamp
    }
  })
}
// 首页-文章-不感兴趣
const articleDislikeAPI = ({ artId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    // headers: {
    //   Authorization: `Bearer ${store.state.token}`
    // },
    data: {
      target: artId
    }
  })
}
// 文章举报的基本接口 二级面板
const articleReportsAPI = ({ artId, type, remark }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    // headers: {
    //   Authorization: `Bearer ${store.state.token}`
    // },
    data: {
      target: artId,
      type,
      remark: type === '0' ? remark : remark || null
    }
  })
}

// 获取所有的数据
const getAllChannelListAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/channels'
  })
}
// 定义修改用户选择频道
const updateUserChannelListAPI = ({ channels }) => {
  return request({
    // 全局修改
    method: 'PUT',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}

export {
  userChannelAPI,
  articlesListAPI,
  articleDislikeAPI,
  articleReportsAPI,
  getAllChannelListAPI,
  updateUserChannelListAPI

}
